package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0912.java
 * @Author : WangRuoyu
 * @Date 2023/11/13 22:55
 */


public class Q0912 {
    private void quickSort(int[] nums, int l, int r) {
        if (l >= r) return;
        int x = nums[l + r >> 1];
        int i = l - 1;
        int j = r + 1;
        while (i < j) {
            while (nums[++i] < x) ;
            while (nums[--j] > x) ;
            if (i < j) {
                int tmp = nums[i];
                nums[i] = nums[j];
                nums[j] = tmp;
            }
        }
        quickSort(nums, l, j);
        quickSort(nums, j + 1, r);
    }

    public int[] sortArray(int[] nums) {
        quickSort(nums, 0, nums.length - 1);
        return nums;
    }

    public static void main(String[] args) {
        Q0912 sl = new Q0912();
        int[] nums = {5, 1, 1, 2, 0, 0};
    }
}